home *** CD-ROM | disk | FTP | other *** search
- Balanced Binary Tree Templates
-
-
- TBPlusTree template
-
- Syntax
- template <class T> class TBPlusTree;
-
- Header File
- btreeimp.h
-
- Description
- Implements a balanced tree of objects of type T.
- TStandardAllocator is used to manage memory.
-
- Type Definitions
- typedef int (*CompFunc) (const T&, void*)
- typedef int (*CondFunc) (const T&, void*)
- typedef void (*IterFunc) (T&, void*)
-
- Public Constructor
- TBPlusTree (void)
-
- Public Member Functions
- int Add (const T& t)
- int Destroy (const T& t)
- int DestroyFirst (void)
- int DestroyLast (void)
- int Detach (const T& t)
- int DetachFirst (void)
- int DetachLast (void)
- T* Find (const T& t) const
- T* First (void) const
- T* FirstThat (CondFunc cond, void* args) const
- void Flush (void)
- void ForEach (IterFunc iter, void* args)
- unsigned GetItemsInContainer (void) const
- int HasMember (const T& t) const
- int IsEmpty (void) const
- T* Last (void) const
- T* LastThat (CondFunc, void* t) const
- T* Search (CompFunc, void* t) const
-
- Syntax
- TBPlusTree (void)
-
- Description
- Creates a tree which is initially empty.
-
- Syntax
- int Add (const T& t)
-
- Description
- Adds a T object to the balanced tree. If the object already exists in the tree,
- Add fails. Add returns 0 if it couldnÆt add the object.
-
- Syntax
- int Destroy (const T& t)
-
- Description
- Removes the object from the tree.
-
- Syntax
- int DestroyFirst (void)
-
- Description
- Removes the first (lowest valued) object from the tree.
-
- Syntax
- int DestroyLast (void)
-
- Description
- Removes the last (highest valued) object from the tree.
-
- Syntax
- int Detach (const T& t)
-
- Description
- Removes the object from the tree.
-
- Syntax
- int DetachFirst (void)
-
- Description
- Removes the first (lowest valued) object from the tree.
-
- Syntax
- int DetachLast (void)
-
- Description
- Removes the last (highest valued) object from the tree.
-
- Syntax
- T* Find (const T& t) const
-
- Description
- Finds the specified object and returns a pointer to it. Returns 0 is the object
- is not found in the tree.
-
- Syntax
- T* First (void) const
-
- Description
- Returns a pointer to the first (lowest valued) object in the tree. Returns 0 is
- the tree is empty.
-
- Syntax
- T* FirstThat (CondFunc cond, void* args) const
-
- Description
- Returns a pointer to the first object in the tree that satisfies a given
- condition. You supply a test function pointer cond that returns true for a
- certain condition. You can pass arbitrary arguments via args. Returns 0 if no
- object in the tree meets the condition.
-
- Syntax
- void Flush (void)
-
- Description
- Removes all the elements in the tree without destroying the tree.
-
- Syntax
- void ForEach (IterFunc iter, void* args)
-
- Description
- ForEach creates an internal iterator to execute the given function for each
- element in the array. The args argument lets you pass arbitrary data to this
- function.
-
- Syntax
- unsigned GetItemsInContainer (void) const
-
- Description
- Returns the number of items in the tree.
-
- Syntax
- int HasMember (const T& t) const
-
- Description
- Returns 1 is the given object is found in the tree, otherwise returns 0.
-
- Syntax
- int IsEmpty (void) const
-
- Description
- Returns 1 is the tree contains no elements, otherwise returns 0.
-
- Syntax
- T* Last (void) const
-
- Description
- Returns a pointer to the last (highest valued) object in the tree. Returns 0 if
- the tree is empty.
-
- Syntax
- T* LastThat (CondFunc cond, void* args) const
-
- Description
- Returns a pointer to the last object in the array that satisfies a given
- condition. You supply a test function pointer, cond, that returns true for a
- certain condition. You can pass arbitrary arguments via args. Returns 0 if no
- object in the tree meets the condition.
-
- Syntax
- T* Search (CompFunc comp, void* args) const
-
- Description
- Returns a pointer an object in the tree that satisfies a given condition. You
- supply a compare function pointer, comp, whoÆs return value directs the search.
- You can pass arbitrary arguments via args. Returns 0 if no object in the tree
- satisfies the search.
-
- If comp returns 0, the search ends, and a pointer to the current object is
- returned.
- If comp returns < 0, the search continues with lower valued objects.
- If comp returns >0, the search continues with greater valued object.
-
-
- TBPlusTreeIterator template
-
- Syntax
- template <class T> class TBPlusTreeIterator;
-
- Header File
- btreeimp.h
-
- Description
- Implements an iterator object to traverse TBPlusTree objects.
-
- Public Constructors
- TBPlusTreeIterator (const TBPlusTree<T> &t)
- TBPlusTreeIterator (const TBPlusTree<T> &t, const T& start, const T& end)
-
- Public Member Functions
- const T& Current (void) const
- void Restart (void)
- void Restart (const T& start, const T& end)
-
- Operators
- const T& operator ++ (int)
- const T& operator ++ (void)
- const T& operator -- (int)
- const T& operator -- (void)
- operator int (void) const
-
- Syntax
- TBPlusTreeIterator (const TBPlusTree<T> &t)
-
- Description
- Creates an iterator to traverse the object t.
-
- Syntax
- TBPlusTreeIterator (const TBPlusTree<T> &t, const T& start, const T& end)
-
- Description
- Creates an iterator to traverse the object t. Limits the range of the iterator
- to all elements whoÆs values lie between start and end inclusive. If start is
- greater than end, the decrement operators should be used.
-
- Note. The tree does not need to contain elements equal to start and end.
-
- Syntax
- const T& Current (void) const
-
- Description
- Returns the current object.
-
- Syntax
- void Restart (void)
-
- Description
- Restarts the iteration over the previous range.
-
- Syntax
- void Restart (const T& start, const T& end)
-
- Description
- Restarts the iteration over the given range. The range is inclusive of start and
- end if values equal to start or end are found in the tree. If start is greater
- than end, the decrement operators should be used.
-
- Syntax
- const T& operator ++ (int)
-
- Description
- Move to the next object, and return the object that was current before the move
- (post-increment).
-
- Syntax
- const T& operator ++ (void)
-
- Description
- Move to the next object, and return the object that was current before the move
- (pre-increment).
-
- Syntax
- const T& operator -- (int)
-
- Description
- Move to the previous object, and return the object that was current before the
- move (post-decrement).
-
- Syntax
- const T& operator -- (void)
-
- Description
- Move to the previous object, and return the object that was current before the
- move (pre-decrement).
-
- Syntax
- operator int (void) const
-
- Description
- Converts the iterator to an integer value for testing if objects remain in the
- iterator. The iterator converts to 0 if nothing remains in the iterator.
-
-
- TIBPlusTree template
-
- Syntax
- template <class T> class TIBPlusTree;
-
- Header File
- btreeimp.h
-
- Description
- Implements a indirect balanced tree of objects of type T.
- TStandardAllocator is used to manage memory.
-
- Type Definitions
- typedef int (*CompFunc) (const T&, void*)
- typedef int (*CondFunc) (const T&, void*)
- typedef void (*IterFunc) (T&, void*)
-
- Public Constructor
- TIBPlusTree (void)
-
- Public Member Functions
- int Add (const T* t)
- int Destroy (const T* t)
- int DestroyFirst (void)
- int DestroyLast (void)
- int Detach (const T* t, DeleteType dt = NoDelete)
- int DetachFirst (DeleteType dt = NoDelete)
- int DetachLast (DeleteType dt = NoDelete)
- T* Find (const T* t) const
- T* First (void) const
- T* FirstThat (CondFunc cond, void* args) const
- void Flush (DeleteType dt = DefDelete)
- void ForEach (IterFunc iter, void* args)
- unsigned GetItemsInContainer (void) const
- int HasMember (const T* t) const
- int IsEmpty (void) const
- T* Last (void) const
- T* LastThat (CondFunc, void* t) const
- T* Search (CompFunc, void* t) const
-
- Syntax
- TIBPlusTree (void)
-
- Description
- Creates a tree which is initially empty.
-
- Syntax
- int Add (const T* t)
-
- Description
- Adds a pointer to the object T to the balanced tree. If the object already
- exists in the tree, Add fails. Add returns 0 if it couldnÆt add the object.
-
- Syntax
- int Destroy (const T* t)
-
- Description
- Removes the object from the tree and deletes it.
-
- Syntax
- int DestroyFirst (void)
-
- Description
- Removes the first (lowest valued) object from the tree and deletes it.
-
- Syntax
- int DestroyLast (void)
-
- Description
- Removes the last (highest valued) object from the tree and deletes it.
-
- Syntax
- int Detach (const T& t, DeleteType dt = NoDelete)
-
- Description
- Removes the object from the tree. The value of dt and the current ownership
- setting determine whether the object itself will be deleted. DeleteType is
- defined in the base class TShouldDelete as enum { NoDelete, DefDelete, Delete }.
- The default value of dt, NoDelete, means that the object will not be deleted
- regardless of ownership. With dt set to Delete, the object will be deleted
- regardless of ownership. If dt is set to DefDelete, the object will be deleted
- only if the tree owns its elements.
-
- Syntax
- int DetachFirst (DeleteType dt = NoDelete)
-
- Description
- Removes the first (lowest valued) object from the tree. The value of dt and the
- current ownership setting determine whether the object itself will be deleted.
- DeleteType is defined in the base class TShouldDelete as enum { NoDelete,
- DefDelete, Delete }. The default value of dt, NoDelete, means that the object
- will not be deleted regardless of ownership. With dt set to Delete, the object
- will be deleted regardless of ownership. If dt is set to DefDelete, the object
- will be deleted only if the tree owns its elements.
-
- Syntax
- int DetachLast (DeleteType dt = NoDelete)
-
- Description
- Removes the last (highest valued) object from the tree. The value of dt and the
- current ownership setting determine whether the object itself will be deleted.
- DeleteType is defined in the base class TShouldDelete as enum { NoDelete,
- DefDelete, Delete }. The default value of dt, NoDelete, means that the object
- will not be deleted regardless of ownership. With dt set to Delete, the object
- will be deleted regardless of ownership. If dt is set to DefDelete, the object
- will be deleted only if the tree owns its elements.
-
- Syntax
- T* Find (const T* t) const
-
- Description
- Finds the specified object and returns a pointer to it. Returns 0 is the object
- is not found in the tree.
-
- Syntax
- T* First (void) const
-
- Description
- Returns a pointer to the first (lowest valued) object in the tree. Returns 0 is
- the tree is empty.
-
- Syntax
- T* FirstThat (CondFunc cond, void* args) const
-
- Description
- Returns a pointer to the first object in the tree that satisfies a given
- condition. You supply a test function pointer cond that returns true for a
- certain condition. You can pass arbitrary arguments via args. Returns 0 if no
- object in the tree meets the condition.
-
- Syntax
- void Flush (DeleteType dt = DefDelete)
-
- Description
- Removes all the elements in the tree without destroying the tree. The value of
- dt determines whether the elements themselves are destroyed. By default, the
- ownership status of the array determines their fate, as explained in the Detach
- member function. You can also set dt to Delete and NoDelete.
-
- Syntax
- void ForEach (IterFunc iter, void* args)
-
- Description
- ForEach creates an internal iterator to execute the given function for each
- element in the array. The args argument lets you pass arbitrary data to this
- function.
-
- Syntax
- unsigned GetItemsInContainer (void) const
-
- Description
- Returns the number of items in the tree.
-
- Syntax
- int HasMember (const T* t) const
-
- Description
- Returns 1 is the given object is found in the tree, otherwise returns 0.
-
- Syntax
- int IsEmpty (void) const
-
- Description
- Returns 1 is the tree contains no elements, otherwise returns 0.
-
- Syntax
- T* Last (void) const
-
- Description
- Returns a pointer to the last (highest valued) object in the tree. Returns 0 if
- the tree is empty.
-
- Syntax
- T* LastThat (CondFunc cond, void* args) const
-
- Description
- Returns a pointer to the last object in the array that satisfies a given
- condition. You supply a test function pointer, cond, that returns true for a
- certain condition. You can pass arbitrary arguments via args. Returns 0 if no
- object in the tree meets the condition.
-
- Syntax
- T* Search (CompFunc comp, void* args) const
-
- Description
- Returns a pointer an object in the tree that satisfies a given condition. You
- supply a compare function pointer, comp, whoÆs return value directs the search.
- You can pass arbitrary arguments via args. Returns 0 if no object in the tree
- satisfies the search.
-
- If comp returns 0, the search ends, and a pointer to the current object is
- returned.
- If comp returns < 0, the search continues with lower valued objects.
- If comp returns >0, the search continues with greater valued object.
-
-
- TIBPlusTreeIterator template
-
- Syntax
- template <class T> class TIBPlusTreeIterator;
-
- Header File
- btreeimp.h
-
- Description
- Implements an iterator object to traverse TIBPlusTree objects.
-
- Public Constructors
- TIBPlusTreeIterator (const TIBPlusTree<T> &t)
- TIBPlusTreeIterator (const TIBPlusTree<T> &t, const T* start, const T* end)
-
- Public Member Functions
- const T* Current (void) const
- void Restart (void)
- void Restart (const T* start, const T* end)
-
- Operators
- const T* operator ++ (int)
- const T* operator ++ (void)
- const T* operator -- (int)
- const T* operator -- (void)
- operator int (void) const
-
- Syntax
- TIBPlusTreeIterator (const TIBPlusTree<T> &t)
-
- Description
- Creates an iterator to traverse the object t.
-
- Syntax
- TIBPlusTreeIterator (const TIBPlusTree<T> &t, const T* start, const T* end)
-
- Description
- Creates an iterator to traverse the object t. Limits the range of the iterator
- to all elements whoÆs values lie between start and end inclusive. If start is
- greater than end, the decrement operators should be used.
-
- Note. The tree does not need to contain elements equal to start and end.
-
- Syntax
- const T* Current (void) const
-
- Description
- Returns the current object.
-
- Syntax
- void Restart (void)
-
- Description
- Restarts the iteration over the previous range.
-
- Syntax
- void Restart (const T* start, const T* end)
-
- Description
- Restarts the iteration over the given range. The range is inclusive of start and
- end if values equal to start or end are found in the tree. If start is greater
- than end, the decrement operators should be used.
-
- Syntax
- const T* operator ++ (int)
-
- Description
- Move to the next object, and return the object that was current before the move
- (post-increment).
-
- Syntax
- const T* operator ++ (void)
-
- Description
- Move to the next object, and return the object that was current before the move
- (pre-increment).
-
- Syntax
- const T* operator -- (int)
-
- Description
- Move to the previous object, and return the object that was current before the
- move (post-decrement).
-
- Syntax
- const T* operator -- (void)
-
- Description
- Move to the previous object, and return the object that was current before the
- move (pre-decrement).
-
- Syntax
- operator int (void) const
-
- Description
- Converts the iterator to an integer value for testing if objects remain in the
- iterator. The iterator converts to 0 if nothing remains in the iterator.
-